package com.supcon.web;

import com.supcon.util.AuthEntity;
import com.supcon.util.UserLoginEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.UUID;


/**
 * @author BeautifulHao
 * @description
 * @create 2019-09-03 10:19
 **/
@RestController
public class AuthController {

    @PostMapping("/api/auth/login")
    public AuthEntity login(@RequestBody UserLoginEntity userLoginEntity){

        AuthEntity authEntity = new AuthEntity();
        authEntity.setSuccess(true);
        authEntity.setCode(200);

        HashMap<String,String> data = new HashMap<>();
        data.put("id", UUID.randomUUID().toString());
        data.put("tokenType", "bearer");
        data.put("authority", "admin");
        data.put("avatar", "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png");
        data.put("userName", "管理员");
        data.put("account", "admin");
        data.put("license", "made by supcon");
        data.put("token", "eyJ0eXAiOiJKc29uV2ViVG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJpc3N1c2VyIiwiYXVkIjoiYXVkaWVuY2UiLCJyb2xlX25hbWUiOiJhZG1pbmlzdHJhdG9yIiwidXNlcl9pZCI6IjEiLCJyb2xlX2lkIjoiMSIsInVzZXJfbmFtZSI6ImFkbWluIiwidG9rZW5fdHlwZSI6ImFjY2Vzc190b2tlbiIsImFjY291bnQiOiJhZG1pbiIsInRlbmFudF9jb2RlIjoiMDAwMDAwIiwiY2xpZW50X2lkIjoic3dvcmQiLCJleHAiOjE1NjM3NjAyOTMsIm5iZiI6MTU2Mzc1NjY5M30.VOTyJYK_6JHrhPIlMLvZOrcLpFCSszgq5JQDuts_xJw");
        data.put("refreshToken", "eyJ0eXAiOiJKc29uV2ViVG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJpc3N1c2VyIiwiYXVkIjoiYXVkaWVuY2UiLCJ1c2VyX2lkIjoiMSIsInRva2VuX3R5cGUiOiJyZWZyZXNoX3Rva2VuIiwiY2xpZW50X2lkIjoic3dvcmQiLCJleHAiOjE1NjQzNjE0OTMsIm5iZiI6MTU2Mzc1NjY5M30.kSPAbng_yDu85QL2WWDn0RT55sgxptifLvC7XIuv7Gk");
        data.put("expiresIn", "3600");
        data.put("loginName",userLoginEntity.getLoginName());
        data.put("loginPwd",userLoginEntity.getLoginPwd());

        authEntity.setData(data);

        return authEntity;
    }
}
